package com.fire.web.modules.all.service.impl;

import com.baomidou.mybatisplus.mapper.Wrapper;
import com.fire.web.modules.all.entity.FireProprietorModel;
import com.fire.web.modules.all.mapper.BuildingZoneMapper;
import com.fire.web.modules.all.entity.BuildingZoneModel;
import com.fire.web.modules.all.mapper.FireProprietorMapper;
import com.fire.web.modules.all.request.AddReportInfoDetail;
import com.fire.web.modules.all.service.IBuildingZoneService;

import org.apache.http.client.utils.DateUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.baomidou.mybatisplus.service.impl.ServiceImpl;
import com.baomidou.mybatisplus.plugins.Page;
import org.springframework.transaction.annotation.Transactional;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 地理编码Service
 *
 * @author Matthew
 * @Date 2019-02-23 16:37
 */
@Service
public class BuildingZoneServiceImpl extends ServiceImpl<BuildingZoneMapper, BuildingZoneModel> implements IBuildingZoneService{

    private static final Logger LOGGER = LoggerFactory.getLogger(BuildingZoneServiceImpl.class);

    @Autowired
    private BuildingZoneMapper buildingZoneMapper;

    @Autowired
    private FireProprietorMapper fireProprietorMapper;

    @Override
    public BuildingZoneModel selectOne(BuildingZoneModel entity){
        return buildingZoneMapper.selectOne(entity);
    }

    @Override
    public List<BuildingZoneModel>selectList(BuildingZoneModel model){
        return buildingZoneMapper.selectListByModel(model);
    }

    @Override
    public Page<BuildingZoneModel> selectPage(int currentPage, int pageSize, Wrapper<BuildingZoneModel> wrapper){
        return selectPage(new Page<BuildingZoneModel>(currentPage,pageSize), wrapper);
    }

    @Override
    public Page<Map<String, Object>> selectMapsPage(int currentPage, int pageSize, Wrapper<BuildingZoneModel> wrapper){
        return selectMapsPage(new Page<BuildingZoneModel>(currentPage,pageSize), wrapper);
    }

    @Override
    @Transactional(rollbackFor = Exception.class)
    public void updateReportInfoAllCoumnById(AddReportInfoDetail req) {
        Map<String,Object>  buildingZone = req.getBuildReportInfo();
	    buildingZone.put("updatetime",new Date());
        buildingZoneMapper.updateMapAllColumnById(buildingZone);

        Map<String,Object>  proprietor = req.getProprietorReportInfo();
	    proprietor.put("updatetime",new Date());
        fireProprietorMapper.updateMapAllColumnById(proprietor);

    }

}
